package com.freewater.springboot.demo.ioc.autowirelist;

import com.freewater.springboot.demo.PackageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;

import java.util.List;

@Slf4j
public class Main {

    public static void main(String[] args) {
        GenericApplicationContext applicationContext = new GenericApplicationContext();
        new XmlBeanDefinitionReader(applicationContext).loadBeanDefinitions("classpath:" + PackageUtils.getClassPathFroClass(Main.class) + "/applicationContext.xml");
        applicationContext.refresh();
        BeanC beanC = applicationContext.getBean("beanC", BeanC.class);
        final List<BaseBean> beans = beanC.getBeans();
        log.info("{}", beans.size());
        for (BaseBean bean : beans) {
            log.info(bean.getClass().toString());
        }
        beanC.getBeanMap().forEach((key, value) -> log.info("key:{}, value:{}", key, value));
    }
}
